package com.sigmatrix.h5.service.db;

import java.math.BigDecimal;
import java.util.List;

import org.springframework.stereotype.Service;

import com.sigmatrix.h5.entity.v2.DisRebateAudit;
import com.sigmatrix.h5.entity.v2.DisRebateDetail;
import com.sigmatrix.h5.exception.MessageException;
import com.sigmatrix.h5.mapper.DisRebateDetailMapper;
import com.sigmatrix.h5.service.v2.CommonDBService;
import com.sigmatrix.h5.web.mode.AccumulatedRebate;
import com.sigmatrix.h5.web.mode.RebateList;

@Service
public class DisRebateDetailDBService extends CommonDBService<DisRebateDetailMapper, DisRebateDetail> {

	/**
	 * 通过dealerId和dealerType统计Amount总数。
	 * 
	 * @param tablePrefix
	 * @param dealerId
	 * @param dealerType
	 * @return
	 */
	public BigDecimal statAmountsByDealerIdAndType(String tablePrefix,Integer dealerId,Integer dealerType){
		if(dealerId==null||dealerType==null){
			throw new MessageException("入参不合法");
		}
		return this.baseMapper.findTotalAmountByDealerIdAndType(tablePrefix,dealerId,dealerType);
	}

	/**
	 * 收支详细。
	 * 
	 * @param tablePrefix
	 * @param dealerId
	 * @param dealerType
	 * @return
	 */
	public List<DisRebateAudit> findRebatedByIdAndType(String tablePrefix,Integer dealerId,Integer dealerType){
		if(dealerId==null||dealerType==null){
			throw new MessageException("入参不合法");
		}
		return this.baseMapper.findRebatedByIdAndType(tablePrefix,dealerId,dealerType);
	}
	
	/**
	 * 统计
	 * 
	 * @param tablePrefix
	 * @param dealerId
	 * @param dealerType
	 * @return
	 */
	public AccumulatedRebate statistic(String tablePrefix,Integer dealerId,Integer dealerType){
		if(dealerId==null||dealerType==null){
			throw new MessageException("入参不合法");
		}
		return this.baseMapper.statistic(tablePrefix,dealerId,dealerType);
	}
	
}
